import { Component } from '@angular/core'
import { Platform } from 'ionic-angular'
import { StatusBar } from '@ionic-native/status-bar'
import { SplashScreen } from '@ionic-native/splash-screen'

import { TabsPage } from '../pages/tabs/tabs'
import { LoginPage } from '../pages/login/login'

import { Storage } from '@ionic/storage'
import { GlobalContract } from '../common/global/globalcontract'

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage: any = LoginPage

  constructor(
    platform: Platform,
    statusBar: StatusBar,
    splashScreen: SplashScreen,
    public local_storage: Storage
  ) {
    local_storage
      .get('token')
      .then(value => {
        if (value) {
          //rootPage为引导页4联页
          this.rootPage = TabsPage

          return
        }
      })
      .catch(err => {
        console.error(err)
      })
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault()
      splashScreen.hide()
    })
  }
}
